<?php
/**
 * Created by PhpStorm.
 * User: 伟鑫
 * Date: 2018/11/23
 * Time: 9:36
 */

namespace app\admin\controller;
use  think\Db;

class Config extends Base
{
    public function index(){
        if (request()->isPost()){
            try{
                $input = $this->request->post();
                $input['addtime'] = time();
                if (isset($input['file']))unset($input['file']);
                $re =  Db::name('config')->where('id',input('id'))->update( $input);
                if ($re){
                    return msg(1,[],'修改成功');
                }else{
                    $this->error($re);
//                    return msg(-1,[],'修改失败');
                }
            }catch (\Exception $e){
                return msg(-1,[],$e->getMessage());
            }

        }
//        var_dump(db('config')->find(1));die;
        $this->assign('config_info',db('config')->find(1));
        return $this->fetch();
    }

}